package com.bjsdzk.common.utils;

import java.util.Random;

/**
 * 胜顶智控平台管理
 * 随机数工具类
 *
 * @author YangTang
 * @time 2019/6/28.
 */
public class RandomUtils {


    public static Integer getNumbers(int len) {

        String bound = "8";
        String base = "1";
        Random random = new Random();
        if (len < 1) {
            return 0;
        } else {
            len--;
            while ((len--) > 0) {
                bound += "9";
                base += "0";
            }
        }
        return random.nextInt(Integer.parseInt(bound)) + Integer.parseInt(base);
    }

    public static String getStrs(int len) {
        String[] cs = new String[]{"a", "b", "c", "d", "e", "f", "g", "h", "j", "k", "m", "n", "p", "q", "r", "s", "z", "w", "y", "x", "v", "t"};
        String res = "";
        Random random = new Random();
        while ((len--) > 0) {
            int index = random.nextInt(cs.length);
            res += cs[index];
        }
        return res;
    }

    public static String getStrAndNumber(int len) {
        String[] cs = new String[]{"a", "2", "b", "3", "c", "4", "d", "5", "j", "k", "m", "n", "p", "q", "e", "6", "f", "7", "g", "8", "h", "9", "r", "s", "z", "w", "y", "x", "v", "t"};
        String res = "";
        Random random = new Random();
        while ((len--) > 0) {
            int index = random.nextInt(cs.length);
            res += cs[index];
        }
        return res;
    }
}
